﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Xml.Linq;
using System.IO;
using System.Deployment.Application;

namespace ParsecClient
{
    /// <summary>
    /// Interaction logic for AboutWindow.xaml
    /// </summary>
    public partial class AboutWindow : Window
    {
        public AboutWindow()
        {
            InitializeComponent();
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }
        }

        private void Hyperlink_NotesNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
        {
            try
            {

                this.Close();
                ParsecWindow mw = ((ParsecWindow)Owner);
                mw.ShowNotes();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }
        }

        private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
        {
            Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
            e.Handled = true;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            txtAppVersion.Text = string.Format("Version: {0}", App.AppVersion);
            txtOtherStuff.Text = "Rendering Mode: " + Enum.GetName(typeof(System.Windows.Interop.RenderMode), System.Windows.Media.RenderOptions.ProcessRenderMode);
        }
        private void btnOpen_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Process.Start(new ProcessStartInfo(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)));
                e.Handled = true;
            }
            catch (Exception ex)
            {
                string response = "Error";
                response += Environment.NewLine + ex.Message;
                MessageBox.Show(response);
            }
        }
        private void btnOpen2_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string folder;
                if (ApplicationDeployment.IsNetworkDeployed)
                {
                    folder = ApplicationDeployment.CurrentDeployment.DataDirectory;
                }
                else
                {
                    folder = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Parsec");
                    if (!Directory.Exists(folder))
                    {
                        Directory.CreateDirectory(folder);
                    }
                }
                Process.Start(new ProcessStartInfo(folder));
                e.Handled = true;
            }
            catch (Exception ex)
            {
                string response = "Error";
                response += Environment.NewLine + ex.Message;
                MessageBox.Show(response);
            }
        }
    }
}
